<!DOCTYPE html>
<html lang="en">
<head>
    <meta charset="UTF-8">
    <title>我的收藏-{{$SEO['title']}}</title>
    <meta name="keywords" content="{{$SEO['keywords']}}"/>
    <meta name="description" content="{{$SEO['description']}}"/>

    <!--公用css引用-->
    @include('front.common.style')

            <!--END/公用css引用-->
    <link rel="stylesheet" href="../dist/css/userCenter.css">
</head>
<body>

@include('front.common.header')

<div class="inbox user-center">
    <div class="layout-margin unend">
        <div class="sidebar-end"></div>
        <div class="sidebar-start">
                @include('front.common.leftnav')

        </div>

        <!--主体部分-->
        <div class="container">
            <div class="container-inner u-order">

                <div class="ui-brd-box1">

                    <div class="tit-2 tit-skin-2">
                        <span class="h">我的收藏</span>
                    </div>

                    <div class="order-list order-list-big">

                        {{--<div class="table-head fn-ohide">--}}
                            {{--<div class="search-box">--}}
                                {{--<form class="bl-form" method="get" action="">--}}
                                    {{--<div class="fn-dib fn-rel keybox">--}}
                                        {{--<input type="text" name="key" placeholder="请输入商品名称" autocomplete="off" class="fn-tinput key">--}}
                                        {{--<span class="fn-dib submit">--}}
                                            {{--<button class="fn-btn btn-submit" type="submit">搜索</button>--}}
                                        {{--</span>--}}
                                        {{--<i class="icon icon-search fn-abs"></i>--}}
                                    {{--</div>--}}
                                {{--</form>--}}
                            {{--</div>--}}
                        {{--</div>--}}

                        @inject('goodsService','App\Interfaces\GoodsService')
                        @inject('pictureService','App\Interfaces\PictureService')
                        @inject('shopService','App\Interfaces\ShopService')

                        <!-- 商品-->
                        @if ($request->get('type')=='GOODS'||$request->get('type')=='')
                        @if ($userCollection->count()>0)
                        <div class="fav-list h170">

                            <ul class="bl-imglist imglist-5col">
                                @foreach($userCollection->items() as $collection)
                                <?php $goods = $goodsService->get($collection->reference_id);?>
                                @if($goods)
                                <li>
                                    <div class="col-space ui-brd-box1">
                                        <a href="/goods/{{$goods->goods_id}}" target="_blank" title="{{$goods->goods_name}}">
                                            <img src="{{$pictureService::thumb($goods->goods_thumb,254,254)}}" alt="{{$goods->goods_name}}">
                                        </a>
                                        <div class="cons">
                                            <p class="info">
                                                <a href="/goods/{{$goods->goods_id}}" class="name link fn-dib-otw" target="_blank" title="{{$goods->goods_name}}">{{$goods->goods_name}}</a>
                                                <span class="price text-color-1">￥{{$goods->market_price}}</span>
                                            </p>

                                            <div class="btns">
                                                <button data-id="{{$goods->goods_id}}" class="J-add-cart fn-btn fn-btn-small fn-mr8">加入购物车</button>
                                                <button  reference_id="{{$goods->goods_id}}" collection-type="GOODS"  class="J-cancel-collection fn-btn fn-btn-small">取消收藏</button>
                                            </div>
                                        </div>
                                    </div>
                                </li>
                                @endif
                                @endforeach
                            </ul>
                        </div>
                        @else
                        <div class="bl-nodata order-nodata">
                            <div class="nodata-text fn-dib">
                                <i class="icon icon-nodata icon-nodata-2"></i>
                                <p class="fn-mb0">您暂时没有收藏任何商品。</p>
                                <a href="/">查看感兴趣的商品&gt;</a>
                            </div>
                        </div>
                        @endif
                        @endif

                        <!-- 店铺-->




                    </div>
                </div>

                <!--分页-->
                <!--  fn-tl/fn-tc/fn-tr 左中右定位; pager-big 大尺寸分页 可不加-->
                <div class="pager fn-tr">
                    {!! $userCollection->appends($filter)->render() !!}
                </div>
                <!--END/分页-->

                <!--猜你喜欢-->
                @inject('goodsService','App\Interfaces\GoodsService')

                <?php
                $randomGoods = $goodsService->getRandomGoods(20);
                ?>
                <div class="js-recommend  recommend-list">
                    <div class="list-head fn-mb16">
                        <div class="tit tit-4">
                            <h3 class="h fn-mr10">
                                为你推荐
                            </h3>
                            <div class="more fn-fl fn-mt4">
                                根据您的浏览记录推荐的商品
                            </div>
                            <a href="javascript:;" class="js-reloadBtn more" data-step="0"><i class="icon icon-load1"></i>换一批</a>
                        </div>
                    </div>
                    <div class="list-body"  style="height: 268px;">
                        <ul class="bl-imglist imglist-5col js-recList ui-100">

                            @if($randomGoods)
                                @foreach($randomGoods as $key=>$value)
                                    <?php
                                    if($key<2) continue;
                                    if($key>20) break;
                                    ?>

                                    <li style="height: 268px;">
                                        <div class="col-space fn-ohide">
                                            <a href="/goods/{{$value->goods_id}}" target="_blank" title="{{$value->goods_name}}">
                                                <img style="width: 168px;height: 168px;" src="@if($value->goods_thumb){{$pictureService->thumb($value->goods_thumb, 200, 200)}} @else # @endif" alt="">
                                            </a>
                                            <div class="fn-ml4 fn-mr4">
                                                <a href="/goods/{{$value->goods_id}}" target="_blank" class="name ui-100 fn-dib-otw" title="{{$value->goods_name}}">{{$value->goods_name}}</a>
                                                <p class="price"><span>{{$value->shop_price}}</span>元</p>
                                            </div>
                                        </div>
                                    </li>
                                @endforeach
                            @endif
                        </ul>
                    </div>
                </div>
                <!--END/猜你喜欢-->

            </div>

        </div>
        <!--END/主体部分-->

    </div>
</div>

<!--公共尾部-->
@include('front.common.footer')

        <!--END/公共尾部-->

<!--公用js引用-->
@include('front.common.script')

        <!--END/公用js引用-->
<script>

    $('.J-cancel-collection').click(function(e){
        var btn = $(e.currentTarget);
        var reference_id = btn.attr('reference_id');
        var type = btn.attr('collection-type');

        layer.confirm('确定要取消收藏吗？',function(){

            $.ajax({
                url:'/my/collection/1',
                type:'DELETE',
                data:{'type':type,'reference_id':reference_id},
                dataType:'json',
                success:function(response){
                    if (response.success==1){
                        var curP=btn.closest('li');
                        var sibLength=curP.siblings('li').length;
                        if(sibLength){
                            curP.slideUp(function(){
                                $(this).remove();
                            });
                        }else{
                            window.location.reload();

                        }
                    }else{

                    }
                }
            });
        });

    });

</script>
<script src="../dist/js/userCenter.js"></script>
</body>
</html>